using score_m.dbc;
using System;
using System.Data;

namespace score_m
{
    public partial class student_info : System.Web.UI.Page
    {
        private DatabaseConnect dbc = new DatabaseConnect();
        private void log(string str)
        {
            System.Diagnostics.Debug.WriteLine(str);
        }

        private void reloadBaseMsg(string sid)
        {
            log(sid);
            DataTable res = dbc.excList($"SELECT * FROM student WHERE sid='{sid}'");
            try
            {
                string name = res.Rows[0].Field<string>("name");
                string gender = res.Rows[0].Field<string>("gender");
                DateTime birth = res.Rows[0].Field<DateTime>("birth");
                string className = res.Rows[0].Field<string>("classid");
                DateTime createTime = res.Rows[0].Field<DateTime>("createTime");
                log(name + gender);
                sidLable.Text = sid;
                nameLabel.Text = name;
                genderLabel.Text = gender;
                birthLabel.Text = birth.ToString("yyyy年MM月dd日");
                classLabel.Text = className;
                createTimeLable.Text = createTime.ToString("yyyy年MM月dd日 hh:mm:ss ");
            }
            catch (Exception e)
            {
                log(e.Message);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["student"] == null)
                    Response.Redirect("login.aspx");
                string sid = Session["student"] as string;
                reloadBaseMsg(sid);
            }
        }
    }
} 